<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCartsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('carts', function (Blueprint $table) {
            $table->id()->comment('购物车表');
            $table->integer('user_id')->index()->comment('用户id');
            $table->integer('product_id')->index()->comment('商品id');
            $table->integer('combination_id')->index()->nullable()->comment('拼团id');
            $table->integer('seckill_id')->index()->nullable()->comment('秒杀id');
            $table->integer('bargain_id')->index()->nullable()->comment('砍价id');
            $table->string('product_attr_unique',16)->comment('商品属性');
            $table->integer('product_num')->comment('商品数量');
            $table->tinyInteger('is_pay')->default(0)->comment('是否已购买0 = 未购买 1 = 已购买');
            $table->tinyInteger('is_new')->default(0)->comment('是否为立即购买0 = 否 1 = 是');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('carts');
    }
}
